// Copyright (C) joyinter
// All rights reserved.
// 
// Author : deng xinguo
// Date   : 2005-5-08
#include "StdAfx.h"
#include ".\joysequencemanager.h"

//##ModelId=44C4B5D2007E
CJoySequenceManager::CJoySequenceManager(void)
{
	m_dwMaxMsgIdRvd=-1;
	m_dwMaxMsgIdSnd=-1;
}

//##ModelId=44C4B5D20080
CJoySequenceManager::~CJoySequenceManager(void)
{

}
//##ModelId=44C4B5D2008C
void CJoySequenceManager::ResetMsgId()
{
	m_dwMaxMsgIdRvd=-1;
	m_dwMaxMsgIdSnd=-1;
}
//##ModelId=44C4B5D20082
void CJoySequenceManager::MsgIdProducer()
{
	m_SequeceLock.Lock();
	m_dwMaxMsgIdSnd++;
	if(m_dwMaxMsgIdSnd>(100000*2000))
	{
		m_dwMaxMsgIdSnd=0;
	}	
	m_SequeceLock.Unlock();
}
//##ModelId=44C4B5D2008D
DWORD CJoySequenceManager::getMaxMsgIdRvd()
{
	//CJoyAutoCS MaxMsgIdGate(m_dwMaxMsgIdRvdLock);

	return m_dwMaxMsgIdRvd;
}
//##ModelId=44C4B5D2008E
DWORD CJoySequenceManager::getMaxMsgIdSnd()
{
	MsgIdProducer();
	return m_dwMaxMsgIdSnd;
}
//##ModelId=44C4B5D2008F
DWORD CJoySequenceManager::MaxMsgIdRvdIncrease()
{
	CJoyAutoCS MaxMsgIdGate(m_dwMaxMsgIdRvdLock);
	++m_dwMaxMsgIdRvd;
	if(m_dwMaxMsgIdRvd>(100000*2000))
	{
		m_dwMaxMsgIdRvd=0;
	}	
	
	return m_dwMaxMsgIdRvd;
}
